using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class DeleteParametersPage : System.Web.UI.Page
{
    GridView gridView;
    SqlDataSource sqlDatatSource;
    protected void Page_Load(object sender, EventArgs e)
    {
        sqlDatatSource = new SqlDataSource();
        sqlDatatSource.ConnectionString =
        WebConfigurationManager.ConnectionStrings[
            "RecruitVietnamDbConnectionString"
            ].ConnectionString;
        ShowData();
        DeleteRecord("7");
        ShowData();
    }

    void ShowData()
    {
        sqlDatatSource.SelectCommandType =
                SqlDataSourceCommandType.Text;
        sqlDatatSource.SelectCommand =
        "select * from tblProvinces";
        gridView = new GridView();
        this.form1.Controls.Add(gridView);
        gridView.DataSource = sqlDatatSource;
        gridView.DataBind();

    }

    void DeleteRecord(string provinceID)
    {

        sqlDatatSource.DeleteCommandType =
        SqlDataSourceCommandType.Text;
        sqlDatatSource.DeleteCommand =
        "Delete from tblProvinces " +
        " where ProvinceID=@ProvinceID";
        Parameter parameter = new
        Parameter("ProvinceID",
        TypeCode.String, provinceID);
        sqlDatatSource.DeleteParameters.Add(parameter);
        sqlDatatSource.Delete();


    }
}
